﻿#pragma once

#include <qtreewidget.h>
#include <qlist.h>
#include <qhash.h>

class ScriptInstruction;
class InstructionLoop;
class ScriptNode;
class TreeWidget_EditScriptList : public QTreeWidget
{
  Q_OBJECT
public:
  enum ListOperation
  {//针对脚本列表的操作
    Clone = 0,
    MoveUp = 1,
    MoveDown = 2,
    Remove = 3
  };
private://property
  QTreeWidgetItem* previousItem = Q_NULLPTR;
public:
  explicit TreeWidget_EditScriptList(QWidget* parent = Q_NULLPTR);
  virtual ~TreeWidget_EditScriptList();
private:
  void circularDelete(QTreeWidgetItem* parent);

public:
  void itemOperation(ListOperation operationFlag);
private slots:
  void slot_itemClicked(QTreeWidgetItem* item, int column);
public:
  //添加新的指令到脚本预览
  void addOperationNameToList(ScriptInstruction* scriptInstruction);

  //geter and seter
public:
  QList<ScriptInstruction*> getScriptList();
  TreeWidget_EditScriptList* setScriptList(QList<ScriptInstruction*> scriptList);
};

class ScriptNode : public QTreeWidgetItem
{
  friend class TreeWidget_EditScriptList;
private:
  ScriptInstruction* scriptInstruction=Q_NULLPTR;
  explicit ScriptNode();
  ScriptNode(const ScriptNode& scriptNode);
  ScriptNode& operator=(const ScriptNode& scriptNode);
  virtual ~ScriptNode();
public:
  virtual QTreeWidgetItem *clone() const override;
};




